sub_dirs=duyebase duyenets duyecap 

bit_long=$(shell getconf LONG_BIT)

all:
	@for subdir in $(sub_dirs);\
	do\
		cd $$subdir; make 2>.error; cd -;\
	done
ifneq ("$(shell find . -name .error -exec cat {} \; | grep 'error:')", "" && "$(shell find . -name .error -exec cat {} \; | grep 'warning:')", "")
	@echo ""
	@echo ""
	@echo ""
	@echo "compile error:"
	@-find . -name .error -exec cat {} \; | grep "error:"
	@echo ""
	@echo "compile warning:"
	@-find . -name .error -exec cat {} \; | grep "warning:"
	@echo ""
	@-find . -name .error -exec rm {} \;
endif
	@echo '===== lib code total lines '`find -name \*.[c,h]* | xargs cat | wc -l` '====='

clean:
	@for subdir in $(sub_dirs);\
	do\
		cd $$subdir;make clean;cd -;\
	done
ifneq ("$(wildcard *.tar.gz)", "")
	@rm duyesdk.tar.gz
endif

cleanall:uninstall
	@for subdir in $(sub_dirs);\
	do\
		cd $$subdir;make cleanall;cd -;\
	done
	@rm -rf ./release
ifneq ("$(wildcard *.tar.gz)", "")
	@rm duyesdk.tar.gz
endif

install:uninstall
	@for subdir in $(sub_dirs);\
	do\
		cd $$subdir;make install;cd -;\
	done
	@rm -rf ./duyesdk*
	@mkdir ./duyesdk
	@cp -rf ./install/* duyesdk
	@tar czvf duyesdk.tar.gz ./duyesdk
	@rm -rf ./duyesdk

uninstall:
	@for subdir in $(sub_dirs);\
	do\
		cd $$subdir;make uninstall;cd -;\
	done
	rm -rf ./install
